/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.Array;
import org.xtext.example.cr.cR.ArrayElement;
import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.Size;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Size</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.SizeImpl#getArray <em>Array</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.SizeImpl#getArrayElement <em>Array Element</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.SizeImpl#getMethod <em>Method</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SizeImpl extends MinimalEObjectImpl.Container implements Size
{
  /**
   * The cached value of the '{@link #getArray() <em>Array</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArray()
   * @generated
   * @ordered
   */
  protected Array array;

  /**
   * The cached value of the '{@link #getArrayElement() <em>Array Element</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArrayElement()
   * @generated
   * @ordered
   */
  protected ArrayElement arrayElement;

  /**
   * The default value of the '{@link #getMethod() <em>Method</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMethod()
   * @generated
   * @ordered
   */
  protected static final String METHOD_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getMethod() <em>Method</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMethod()
   * @generated
   * @ordered
   */
  protected String method = METHOD_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SizeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.SIZE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Array getArray()
  {
    if (array != null && array.eIsProxy())
    {
      InternalEObject oldArray = (InternalEObject)array;
      array = (Array)eResolveProxy(oldArray);
      if (array != oldArray)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, CRPackage.SIZE__ARRAY, oldArray, array));
      }
    }
    return array;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Array basicGetArray()
  {
    return array;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setArray(Array newArray)
  {
    Array oldArray = array;
    array = newArray;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.SIZE__ARRAY, oldArray, array));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ArrayElement getArrayElement()
  {
    return arrayElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetArrayElement(ArrayElement newArrayElement, NotificationChain msgs)
  {
    ArrayElement oldArrayElement = arrayElement;
    arrayElement = newArrayElement;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.SIZE__ARRAY_ELEMENT, oldArrayElement, newArrayElement);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setArrayElement(ArrayElement newArrayElement)
  {
    if (newArrayElement != arrayElement)
    {
      NotificationChain msgs = null;
      if (arrayElement != null)
        msgs = ((InternalEObject)arrayElement).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.SIZE__ARRAY_ELEMENT, null, msgs);
      if (newArrayElement != null)
        msgs = ((InternalEObject)newArrayElement).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.SIZE__ARRAY_ELEMENT, null, msgs);
      msgs = basicSetArrayElement(newArrayElement, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.SIZE__ARRAY_ELEMENT, newArrayElement, newArrayElement));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getMethod()
  {
    return method;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMethod(String newMethod)
  {
    String oldMethod = method;
    method = newMethod;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.SIZE__METHOD, oldMethod, method));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.SIZE__ARRAY_ELEMENT:
        return basicSetArrayElement(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.SIZE__ARRAY:
        if (resolve) return getArray();
        return basicGetArray();
      case CRPackage.SIZE__ARRAY_ELEMENT:
        return getArrayElement();
      case CRPackage.SIZE__METHOD:
        return getMethod();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.SIZE__ARRAY:
        setArray((Array)newValue);
        return;
      case CRPackage.SIZE__ARRAY_ELEMENT:
        setArrayElement((ArrayElement)newValue);
        return;
      case CRPackage.SIZE__METHOD:
        setMethod((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.SIZE__ARRAY:
        setArray((Array)null);
        return;
      case CRPackage.SIZE__ARRAY_ELEMENT:
        setArrayElement((ArrayElement)null);
        return;
      case CRPackage.SIZE__METHOD:
        setMethod(METHOD_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.SIZE__ARRAY:
        return array != null;
      case CRPackage.SIZE__ARRAY_ELEMENT:
        return arrayElement != null;
      case CRPackage.SIZE__METHOD:
        return METHOD_EDEFAULT == null ? method != null : !METHOD_EDEFAULT.equals(method);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (method: ");
    result.append(method);
    result.append(')');
    return result.toString();
  }

} //SizeImpl
